package com.ssy.lingxi.workflow.entity;

import com.ssy.lingxi.workflow.handler.converter.JpaJsonToMemberRoleBOConverter;
import com.ssy.lingxi.workflow.model.bo.MemberRoleBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 前端菜单与用户角色的关联
 * @author 万宁
 * @version 2.0.0
 * @date 2021-04-28
 */
@Entity
@Table(schema = "public", name = "wf_internal_process_role", indexes = {@Index(name = "wf_internal_process_role_url_idx", columnList = "url"), @Index(name = "wf_internal_process_role_source_idx", columnList = "source")})
public class InternalProcessRole implements Serializable {
    private static final long serialVersionUID = -5565981443636100891L;

    /**
     * 主键名称id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="internal_process_role_seq")
    @SequenceGenerator(sequenceName="wf_internal_process_role_seq", name="internal_process_role_seq",allocationSize = 1)
    private Long id;

    /**
     * 菜单Url
     */
    @Column(columnDefinition = "varchar(400)")
    private String url;

    /**
     * 前端Url所在的客户端
     */
    @Column
    private Integer source;

    /**
     * 有权限访问此菜单的会员用户角色
     */
    @Convert(converter = JpaJsonToMemberRoleBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<MemberRoleBO> roles;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getSource() {
        return source;
    }

    public void setSource(Integer source) {
        this.source = source;
    }

    public List<MemberRoleBO> getRoles() {
        return roles;
    }

    public void setRoles(List<MemberRoleBO> roles) {
        this.roles = roles;
    }
}
